package com.fenghongzhang.day005;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;


/**
 * A simple {@link Fragment} subclass.
 */
public class SendFragment extends Fragment {
    private EditText etId;
    private Button buttonId;
    public SendFragment() {
        // Required empty public constructor
    }

    private MyLintener myLintener;
    public interface MyLintener{
        void eat(String s);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_send, container, false);

        //静态有id.动态有tag
        myLintener = (MyLintener) getActivity().getSupportFragmentManager().findFragmentByTag("down"); //和系统的一对象吗

        etId = (EditText) inflate.findViewById(R.id.et_id);
        buttonId = (Button) inflate.findViewById(R.id.button_id);

        buttonId.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String string = etId.getText().toString();
                myLintener.eat(string);
            }
        });


        return inflate;
    }

}
